﻿using System.Collections.Generic;
using System.Linq;
using LINQtoFxCop.Core;
using Microsoft.FxCop.Sdk;

namespace LINQtoFxCop.Flaws.Design
{
  internal sealed class DesignAvoidEmptyInterfaces : FlawsIntrospectionRule
  {
    public DesignAvoidEmptyInterfaces()
      : base("DesignAvoidEmptyInterfaces")
    { }

    protected override IEnumerable<QueryResult> Query()
    {
      return
        from @interface in Interfaces
        where !@interface.Members.OfType<Method>().HasItem() &&
              @interface.Interfaces.Count < 2
        select Result(@interface);
    }
  }
}